package cn.edu.hbvtc.qms.web.struts.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import cn.edu.hbvtc.qms.domain.Clazz;
import cn.edu.hbvtc.qms.domain.ClazzArrangement;
import cn.edu.hbvtc.qms.domain.Student;
import cn.edu.hbvtc.qms.domain.Term;
import cn.edu.hbvtc.qms.domain.User;
import cn.edu.hbvtc.qms.service.IEvaluationService;
import cn.edu.hbvtc.qms.service.IManagementService;

public class CourseQualityManagementAction extends AbstractBaseDispatchAction {

	private IEvaluationService evaluationService = null;
	private IManagementService managementService = null;

	public IEvaluationService getEvaluationService() {
		return evaluationService;
	}

	public void setEvaluationService(IEvaluationService evaluationService) {
		this.evaluationService = evaluationService;
	}

	public IManagementService getManagementService() {
		return managementService;
	}

	public void setManagementService(IManagementService managementService) {
		this.managementService = managementService;
	}

	public ActionForward courseEvaluateList(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// 获得当前登录用户
		User user = managementService.findUserByUsername(this.getPrincipal()
				.getUsername());
		// 获得当前登录学生相关信息
		Student student = managementService.findStudentById(user.getId());
		request.setAttribute("student", student);
		
		Term term = managementService.findTermOfNow();
		Clazz clazz = student.getClazz();
		List<ClazzArrangement> clazzArrangementList = evaluationService.findClazzArrangementByTerm(term, clazz);

		request.setAttribute("caList", clazzArrangementList);
		
		return mapping.findForward("courseEvaluateList");
	}
}
